<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = Math.ceil(Math.random() * 10)
      for (let i = 8; i > 0; i--) {
        let enter = +prompt("请输入你猜的数")
        if (enter == arr) {
          alert("恭喜您猜对了")
        } else {
          alert(`对不起，您猜错了，剩余${i - 1}次`)
        }
      }
    </script>
  </body>
</html>
